package com.kunya.product.service.impl.specification;

import com.kunya.common.common.ResponseCode;
import com.kunya.common.common.ServerResponse;
import com.kunya.product.dao.specification.KindAttributeMapper;
import com.kunya.product.po.KindAttribute;
import com.kunya.product.service.specofocation.IKindAttributeService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zp
 * @Description: 商品对应的规格属性service层接口实现
 * @date 2018/7/5 13:29
 */
@Service("iKindAttributeService")
public class KindAttributeServiceImpl implements IKindAttributeService{

    @Autowired
    private KindAttributeMapper kindAttributeMapper;

    /**
     * @author zp
     * @Description: 根据kindIds查询 列表
     * @param
     * @date 2018/7/5 14:18
     */
    public ServerResponse<List<KindAttribute>> getByKindIds(List<Long> kindIds,String tablePrefix){
        if(null==kindIds||kindIds.isEmpty()|| StringUtils.isEmpty(tablePrefix)){
            return ServerResponse.createByErrorCodeMessage(ResponseCode.ILLEGAL_ARGUMENT.getCode(),ResponseCode.ILLEGAL_ARGUMENT.getDesc());
        }
        List<KindAttribute> kindAttributes=kindAttributeMapper.selectByKindIds(kindIds,tablePrefix);//如未查询到数据，返回长度为0的list,交由上层调用者处理
        return ServerResponse.createBySuccess(kindAttributes);
    }
}
